<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="js/ajax.js"></script>
</head>
<body>
    <button onclick="sendData()">发送</button>
    <script>
        let sendData = function (){
            ajax({
                url:"2.php",
                type:"post",
                data:{
                    a:1,
                    b:2
                },
                success:function(res){
                    alert(res)
                }
            });
        }
    </script>
</body>
</html>